package edu.xidian.bdilab.jrbigdata.controller.government;

import edu.xidian.bdilab.jrbigdata.controller.response.ResponseResult;
import edu.xidian.bdilab.jrbigdata.service.government.creditRating.CreditingRatingService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName CreditRatingController
 * @Description TODO
 * @Author tuantuan
 * @Date 2019/4/14 下午8:02
 * @Version 1.0
 * @Attention Copyright (C), 2004-2019, BDILab, XiDian University
 **/
@CrossOrigin
@RestController
@Api(tags = {"creditRating-企业信用公示功能"})
public class CreditRatingController {
    @Autowired
    CreditingRatingService creditingRatingService;

    @ResponseBody
    @ApiOperation("获取未被评级的企业相关信息")
    @RequestMapping(value = "government/getUnratedEnterprise", method = RequestMethod.POST)
    public ResponseResult getUnratedEnterprise(@RequestParam(defaultValue = "1")@ApiParam(value = "页码") int pageNum,
                                                @RequestParam(defaultValue = "10")@ApiParam(value = "每页记录数") int pageSize
    )throws Exception{
        ResponseResult responseResult=creditingRatingService.getUnratedEnterprise(pageNum,pageSize);
        return responseResult;
    }

    @ResponseBody
    @ApiOperation("对企业进行评级")
    @RequestMapping(value = "government/rateEnterprise", method = RequestMethod.POST)
    public ResponseResult ratedEnterprise(@RequestParam@ApiParam(value = "企业用户名即social_code") String userName,
                                          @RequestParam@ApiParam(value = "等级") int creditRate
    )throws Exception{
        ResponseResult responseResult=creditingRatingService.rateEnterprise(userName,creditRate);
        return responseResult;
    }

    @ResponseBody
    @ApiOperation("获取已被评级的企业相关信息，以及评级信息")
    @RequestMapping(value = "government/getRatedEnterprise", method = RequestMethod.POST)
    public ResponseResult getRatedEnterprise(@RequestParam(defaultValue = "1")@ApiParam(value = "页码") int pageNum,
                                               @RequestParam(defaultValue = "10")@ApiParam(value = "每页记录数") int pageSize
    )throws Exception{
        ResponseResult responseResult=creditingRatingService.getRatedEnterprise(pageNum,pageSize);
        return responseResult;
    }

}
